{template 'common/header'}
	<ul class="nav nav-tabs">
		<li class="active"><a href="{php echo create_url('site/module/post', array('name' => 'qrcode'));}">生成二维码</a></li>
		<li><a href="{php echo create_url('site/module/list', array('name' => 'qrcode'));}">管理二维码</a></li>
		<li><a href="{php echo create_url('site/module/display', array('name' => 'qrcode'));}">扫描统计</a></li>
	</ul>
	<div class="main">
	<form class="form-horizontal form" action="" method="post" onsubmit="return formcheck(this)">
		<input type="hidden" name="id" value="{$row['id']}" />
		<h4>生成二维码</h4>
		<table class="tb">
			<tr>
				<th><label for="scene-name">场景名称</label></th>
				<td>
					<input type="text" id="scene-name" class="span4" placeholder="" name="scene-name" value="{$row['name']}" />
				</td>
			</tr>
			<tr>
				<th><label for="keyword">关联关键字</label></th>
				<td>
					<input type="text" id="keyword" class="span2" name="keyword" value="{$row['keyword']}" /><span class="help-block">二维码对应关键字, 用户扫描后系统将通过场景ID返回关键字到平台处理.</span>
				</td>
			</tr>
			{if empty($id)}
			<tr>
				<th><label for="">二维码类型</label></th>
				<td>
					<label for="radio_1" class="radio inline"><input type="radio" name="qrc-model" id="radio_1" onclick="$('#displayorder').show();" value="1" {if empty($row['model']) || $row['model'] == 1}checked="checked"{/if} /> 临时</label>
					<label for="radio_0" class="radio inline"><input type="radio" name="qrc-model" id="radio_0" onclick="$('#displayorder').hide();" value="2" {if $row['model'] == 2}checked="checked"{/if} /> 永久</label>
					<span class="help-block">目前有2种类型的二维码, 分别是临时二维码和永久二维码, 前者有过期时间, 最大为1800秒, 但能够生成较多数量, 后者无过期时间, 数量较少(目前参数只支持1--10000).</span>
				</td>
			</tr>
			{/if}
			<tr id="displayorder" {if $row['model'] == 2} style="display:none;"{/if}>
				<th><label for="expire-seconds">过期时间</label></th>
				<td>
					<input type="text" id="expire-seconds" class="span2" placeholder="" name="expire-seconds" value="1800" />
					<span class="help-block">临时二维码过期时间, 最大为1800秒.</span>
				</td>
			</tr>
			<tr>
				<th></th>
				<td>
					<button type="submit" class="btn btn-primary span3" name="submit" value="提交">提交</button>
					<input type="hidden" name="token" value="{$_W['token']}" />
					<input type="hidden" name="do" value="post" />
				</td>
			</tr>
		</table>
	</form>
	</div>
<script type="text/javascript">
function formcheck(form) {
	if (form['scene-name'].value == '') {
		message('抱歉，场景名称为必填项，请返回修改！', '', 'error');
		return false;
	}
	if (form['keyword'].value == '') {
		message('抱歉，场景管理关键字为必填项，请返回修改！', '', 'error');
		return false;
	}
	//console.log(form['qrc-model'].value);
	if($("#radio_1").attr("checked") == "checked") {
		if (form['expire-seconds'].value == '') {
			message('抱歉，临时二维码过期时间为必填项，请返回修改！', '', 'error');
			return false;
		}
		var r2 = /^\+?[1-9][0-9]*$/;
		if(!r2.test(form['expire-seconds'].value)){
			message('抱歉，临时二维码过期时间必须为正整数，请返回修改！', '', 'error');
			return false;
		}
		if(parseInt(form['expire-seconds'].value)<30 || parseInt(form['expire-seconds'].value)>1800) {
			message('抱歉，临时二维码过期时间必须在30-1800秒之间，请返回修改！', '', 'error');
			return false;
		}
		
	}
	return true;
}
</script>
{template 'common/footer'}